<template>
	<view class="ikz">
    <ikz-loading  :css-data="loading_css"></ikz-loading>
    <view class="ikz-log" v-if="show_info.length">
      <view class="ikz-log-item" v-for="(item,index) in show_info" :key="index">
        <view class="ikz-log-tips">
          <view class="ikz-log-box">
            <view class="ikz-log-title">{{item.desc}}</view>
          </view>
          <view class="ikz-log-time">{{item.createtime}}</view>
        </view>
        <view class="ikz-log-price">
          ￥{{item.receive_profit}}
        </view>
      </view>
    </view>
    <view class="ikz-more" v-if="load_more == 4">
      ——我也是有底线的——
    </view>
    <view class="ikz-more" v-if="load_more == 5">
      <image class="ikz-empty" src="/static/empty.png"></image>
    </view>
	</view>
</template>

<script>
  import ikzLoading from '@/pages/Component/Public/Loading/loading.vue';
  var app = getApp();
  import ikz from '@/pages/Common/tools.js';
  export default {
    components: {
      ikzLoading
    },
    data() {
      return {
        loading_css:{
          display:'flex',
        },
        amount:'',
        page:1,
        limit:20,
        load_more:2,
        show_info:[],
        status:''
       }
    },
    onLoad(options) {
      this.status = options.status;
      this.priceInfo((res)=>{
        this.loading_css.display = 'none';
      })
    },
    onReachBottom() {
      if(this.load_more == 2){
        this.page++;
        this.load_more = 3;
        this.priceInfo((res)=>{
        });
      }
    },
    onPullDownRefresh() {
      this.page = 1;
      this.priceInfo((res)=>{
        uni.stopPullDownRefresh();
      });
    },
    methods: {
      priceInfo(fn){
        if(this.status == 2){
          var path = '/xyb/user_receive/profit_list'
        }else{
          var path = '/xyb/agent/profit_list'
        }
        var data = {
          page:1,
          limit:20
        }
        ikz.post(path,data,(res)=>{
          if(res.data.code){
            var temp_list = res.data.data.data;
            if(this.page != 1){
              for(var i = 0;i<temp_list.length;i++){
                this.show_info.push(temp_list[i]);
              }
            }else{
              this.show_info = temp_list;
            }
            if(temp_list.length == this.limit){
              this.load_more = 2;
            }else{
              if(this.page == 1){
                if(temp_list.length == 0){
                  this.load_more = 5;
                }else {
                  this.load_more = 4;
                }
              }else{
                this.load_more = 4;
              }
            }
            this.$forceUpdate();
          } else {
            uni.showModal({
              title: '提示',
              content: res.data.msg,
              showCancel: false,
              success: function(res) {}
            });
          }
          fn();
        });
      },
    }
  };
</script>

<style >
  page{
    width: 100%;
    height: 100%;
    background:#F3F3F3;
  }
  .ikz-log{
    box-sizing: border-box;
    padding: 20rpx;
    width: 95%;
    margin: 20rpx auto;
    border-radius: 15rpx;
    background: #fff;
  }
  .ikz-log-box{
    display: flex;
    align-items: center;
  }
  .ikz-log-item{
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20rpx;
  }
  .ikz-log-title{
    font-weight: 600;
  }
  .ikz-log-card{
    box-sizing: border-box;
    padding: 0 10rpx;
    background: #009423;
    color: #fff;
    border-radius: 20rpx;
    font-size: 25rpx;
    margin-left: 20rpx;
  }
  .ikz-log-card1{
    box-sizing: border-box;
    padding: 0 10rpx;
    background: #FF7070;
    color: #fff;
    border-radius: 20rpx;
    font-size: 25rpx;
    margin-left: 20rpx;
  }
  .ikz-log-card2{
    box-sizing: border-box;
    padding: 0 10rpx;
    background: #FBAB7E;
    color: #fff;
    border-radius: 20rpx;
    font-size: 25rpx;
    margin-left: 20rpx;
  }
  .ikz-log-time{
    color: #888888;
    font-size: 28rpx;
    margin-top: 15rpx;
  }
  .ikz-log-price{
    color: #FF0000;
    font-size: 35rpx;
  }
  .ikz-more{
    width:100%;
    text-align: center;
    line-height: 50rpx;
    color: #999999;
    padding-bottom: 25rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 25rpx;
  }
  .ikz-empty{
    width: 150rpx;
    height: 150rpx;
    margin-bottom: 20rpx;
    margin-top: 150rpx;
  }
</style>
